package com.leo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Author: duan
 * @Date: Create in 17:23 2020/10/14
 */
@WebServlet("/haha")
public class HahaServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("hahadoget");
        System.out.println("HahaServlet:::doget");
        resp.setContentType("text/plain; charset=UTF-8");
        PrintWriter writer = resp.getWriter();
        writer.println("HahaServlet成功了");
        String account = req.getParameter("account");
        String password = req.getParameter("password");
        System.out.println("account:" + account + ", password:" + password);
        req.setAttribute("account", account);
        req.setAttribute("password", password);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("hahadopost");
    }
}
